package cc.vv.btpartyjob.homepage.adapter

import android.annotation.SuppressLint
import android.os.Build
import android.support.annotation.RequiresApi
import android.text.TextUtils
import android.widget.TextView
import cc.vv.baselibrary.adapter.SimpleCommonAdapter
import cc.vv.baselibrary.adapter.holder.ExtendViewHolder
import cc.vv.btpartyjob.homepage.R
import cc.vv.btpartyjob.homepage.moudel.bean.MineProjectWarningObj

/**
 * 预警通知adapter
 * Created by Chen.qi on 2018/10/24.
 */
class WarningNoticeAdapter(layoutResId: Int) : SimpleCommonAdapter<MineProjectWarningObj>(layoutResId) {
    @SuppressLint("SetTextI18n")
    @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
    override fun convert(helper: ExtendViewHolder, item: MineProjectWarningObj, position: Int) {
        //项目名称
        val tvProjectName = helper.getView<TextView>(R.id.tv_imwP_projectName)
        tvProjectName?.text = item.projectName

        //负责人
        val principalName = helper.getView<TextView>(R.id.tv_imwP_createTime)
        principalName?.text = item.principal

        //申报时间
        val tvDeclareTime = helper.getView<TextView>(R.id.tv_imwP_declareTime)
        if (!TextUtils.isEmpty(item.declarationTime) && item.declarationTime!!.length > 10) {
            val substring = item.declarationTime!!.substring(0, 10)
            tvDeclareTime?.text = "申报时间：$substring"
        } else {
            tvDeclareTime?.text = "申报时间：${item.declarationTime}"
        }

        //预警时间
        val tvYuJinTime = helper.getView<TextView>(R.id.tv_imwP_waringTime)
        if (!TextUtils.isEmpty(item.warningTime) && item.warningTime!!.length > 10) {
            val substring = item.warningTime!!.substring(0, 10)
            tvYuJinTime?.text = "预警时间：$substring"
        } else {
            tvYuJinTime?.text = "申报时间：${item.warningTime}"
        }
    }
}